package zilvic.game.character;

import org.duncan.Math2D.Point2D;
import zilvic.game.Game;
import zilvic.game.KeyInputHandler;
import zilvic.game.room.entity.Entity;
import zilvic.game.room.entity.actor.Actor;

/**
 * A player-controlled character in the game.
 * @author Duncan
 */
public abstract class Character extends Actor {
    /**
     * Character constructor. The super-constructor should always be executed.
     * @param position The position of the character.
     */
    public Character(Point2D position) {
        super (position);
    }

    
    /**
     * Is called whenever the character has the ability to change direction.
     */
    @Override
    public void requestDirection() {
        setMoving(true);
        if      (Game.getInputHandler().isKeyDown(KeyInputHandler.KEY_MOVE_DOWN))
            setDirection(DIRECTION_DOWN);
        else if (Game.getInputHandler().isKeyDown(KeyInputHandler.KEY_MOVE_RIGHT))
            setDirection(DIRECTION_RIGHT);
        else if (Game.getInputHandler().isKeyDown(KeyInputHandler.KEY_MOVE_UP))
            setDirection(DIRECTION_UP);
        else if (Game.getInputHandler().isKeyDown(KeyInputHandler.KEY_MOVE_LEFT))
            setDirection(DIRECTION_LEFT);
        else setMoving(false);
    }

    /**
     * Is called whenever the user is interacting with something. The given
     * entity is the entity interacted with. If there is no entity in front of
     * the character then null is passed as an argument.
     *
     * Usually the first hand is used to attack something.
     *
     * This method should be overidden when creating a new character.
     * @param entity The entity in front of the character or null.
     */
    public abstract void firstHandInteraction(Entity entity);

    /**
     * Is called whenever the user is interacting with something. The given
     * entity is the entity interacted with. If there is no entity in front of
     * the character then null is passed as an argument.
     *
     * Usually the first hand is used to pick up something or to talk to someone.
     *
     * This method should be overidden when creating a new character.
     * @param entity The entity in front of the character or null.
     */
    public abstract void secondHandInteraction(Entity entity);
}